/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package todonet.serializers;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import javax.xml.stream.XMLStreamException;
import todonet.ToDoTask;

/**
 *
 * @author LaoTzi
 */
public class SaveTest {
    public static void main(String [] args) throws FileNotFoundException, XMLStreamException, IOException
    {
        File f1 = new File("C:\\SaveTest");
        ToDoXmlSerializer serializer = new ToDoXmlSerializer();
        //List<ToDoTask> list = new ArrayList<ToDoTask>();
        ToDoTask t1 = new ToDoTask();
        t1.setTitle("New York");
        t1.setDateOfEnd(new Date("03/03/2011"));
        //list.add(t1);
        serializer.Save(new FileOutputStream("t1.xml"),t1);
        //System.out.println(f1);

        //String xmlExample = "<todonet.ToDoTask><__title>Встать в 8:00</__title><__important>NORMAL</__important><__percentComplete>0</__percentComplete></todonet.ToDoTask>";
        ToDoTask _t1 = serializer.Load(new FileInputStream("t1.xml"));
        System.out.println(_t1.getTitle());
        System.out.println(_t1.getDateOfEnd());
    }

}
